package nn.functions;

public class SigmoidFunction implements ActivationFunction {
	@Override
	public float calculateValue(float in) {
		// 1/1+e(-x)
		return (float) (1 / (1 + Math.exp(-in)));
	}

	@Override
	public String getType() {
		return ActivationFunctionFactory.SIG_FUNC;
	}

	@Override
	public float calculateDerivative(float in) {
		double exp = Math.exp(in);
		return (float) (exp / ((exp + (double)1) * (exp + (double)1)));
	}
}
